package com.ja.openchat.viewmodels;

import android.app.Activity;
import android.app.Application;

import androidx.annotation.NonNull;

import com.ja.openchat.ui.contact.search.PublicSearchSectionAdapter;
import com.zy.openchat.core.manager.TgEvent;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import me.goldze.mvvmhabit.base.BaseModel;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;


public class PublicChatSearchViewModel extends BaseViewModel {

    private Activity mContext;
    private PublicSearchSectionAdapter publicSearchSectionAdapter;

    public PublicChatSearchViewModel(@NonNull Application application, BaseModel mRepository) {
        super(application);
    }

    public void setContext(Activity mContext) {
        this.mContext = mContext;
    }


    public BindingCommand back_click = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            finish();
        }
    });

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onTgEvent(final TgEvent tg_event) {
        switch (tg_event.event) {
            case EUser_Td_Contact_Photo_Ok: {
                publicSearchSectionAdapter.notifyDataSetChanged();
            }
            break;
        }
    }

    public void setAdapter(PublicSearchSectionAdapter publicSearchSectionAdapter) {
        this.publicSearchSectionAdapter = publicSearchSectionAdapter;
    }
}
